﻿// 客户信息管理

function CifCust() {

    var CifCustFields = new Array(
        { name: 'Id', type: 'string' },
        { name: 'CustNo', type: 'string' },
        { name: 'CertTp', type: 'string' },
        { name: 'CertNo', type: 'string' },
        { name: 'CustNa', type: 'string' },
        { name: 'OffiTL', type: 'string' },
        { name: 'HomeTL', type: 'string' },
        { name: 'MobiTL', type: 'string' },
        { name: 'MailCD', type: 'string' },
        { name: 'MailAD', type: 'string' },
        { name: 'E_Mail', type: 'string' }
    );

    // 定义filters
    var filters = new Ext.ux.grid.GridFilters({
        encode: true,
        filters: [{
            dataIndex: 'Brand', // 品牌
            options: ['丰田', '大众', '本田'],
            //options : DeptStore.collect('Name'),
            type: 'list'
        }]
    });

    //查询语句
    filters.buildQuery = function (filters) {
        var p = {}, i, f, root, dataPrefix, key, tmp, len = filters.length;
        if (!this.encode) {
            for (i = 0; i < len; i++) {
                f = filters[i];
                root = [this.paramPrefix, '[', i, ']'].join('');
                p[root + '[field]'] = f.field;

                dataPrefix = root + '[data]';
                for (key in f.data) {
                    p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
                }
            }
        } else {
            tmp = [];
            for (i = 0; i < len; i++) {
                f = filters[i];
                tmp.push(Ext.apply({}, {
                    field: f.field
                }, f.data));
            }
            if (tmp.length > 0) {
                p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
            }
        }
        return p;
    };

    // 机构Combo Store
    var DeptStore = new Ext.data.JsonStore({
        url: '/InfraHospUser/GetDeptList',
        root: 'data',
        totalProperty: 'total',
        id: 'Id',
        fields: [{
            name: 'Id',
            type: 'string'
        }, {
            name: 'Name',
            type: 'string'
        }, {
            name: 'Code',
            type: 'string'
        }]
    });

    DeptStore.load({
        callback: function (r) {
            filters.addFilter({
                type: 'list',
                dataIndex: 'CurrentDep',
                options: JsHelper.GetFilterListData(r, 'Code', 'Name')
            });
        }
    });

    //字典Store
    var DictStore = function (dictCategory) {
        var dictionaryStore = new Ext.data.JsonStore({
            url: '/InfraDictionary/GetPlistByCategoryCode?Code=' + dictCategory,
            root: 'data',
            totalProperty: 'total',
            id: 'Code',
            fields: [{
                name: 'Id',
                type: 'string'
            }, {
                name: 'Name',
                type: 'string'
            }, {
                name: 'Code',
                type: 'string'
            }]
        });
        return dictionaryStore;
    }

    //与筛选有关的字典dictstore
    var DictFilterStore = function (dictCategory, filters, text, value) {
        var dictStore = DictStore(dictCategory);
        dictStore.load({
            callback: function (r) {
                filters.addFilter({
                    type: 'list',
                    dataIndex: dictCategory,
                    options: JsHelper.GetFilterListData(r, value, text)
                });
            }
        });
        return dictStore;
    }

    //总仓Deport Store
    var TDeportStore = DictFilterStore('TDeport', filters, 'Name', 'Name');
    var CifCustTypeStore = DictFilterStore('BCT', filters, 'Name', 'Name');

    // 定义表单 客户信息Reader
    var CifCustFormReader = new Ext.data.JsonReader({
        root: 'data',
        fields: CifCustFields
    });

    // 定义表格 客户信息store
    var itemGridStore = new Ext.data.Store({
        url: "/BCar/GetPlistAll",
        remoteSort: true,
        reader: new Ext.data.JsonReader({
            root: 'data',
            totalProperty: 'total',
            id: 'Id',
            fields: CifCustFields
        }),
        listeners: {
            'remove': function (thiz, record, index) {
                Ext.Ajax.request({
                    url: '/CifCust/Delete?Id=' + record.data.Id,
                    success: function (response, opts) {
                        var result = Ext.util.JSON.decode(response.responseText);
                        if (result.success == false) {
                            JsHelper.ShowError(result.msg);
                            itemGridStore.insert(0, record);
                        }
                    }
                });
            }
        }
    });
    itemGridStore.setDefaultSort('CreateTime', 'ASC'); // 设置默认排序

    // 定义表格选择方式
    var sm = new Ext.grid.CheckboxSelectionModel();

    // 定义Grid表格列
    var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), sm, {
        header: "客户号",
        dataIndex: 'CustNo',
        sortable: true
    }, {
        header: "证件类型",
        dataIndex: 'CertTp',
        sortable: true
    }, {
        header: "证件号码",
        dataIndex: 'CertNo',
        sortable: true
    }, {
        header: "客户姓名",
        dataIndex: 'CustNa',
        sortable: true
    }, {
        header: "性别",
        dataIndex: 'Gender'
    }, {
        header: "办公电话",
        dataIndex: 'HomeTL'
    }, {
        header: "家庭电话",
        dataIndex: 'HomeTL'
    }, {
        header: "手机",
        dataIndex: 'MobiTL'
    }, {
        header: "邮编",
        dataIndex: 'MailCD'
    }, {
        header: "地址",
        dataIndex: 'MailAD'
    }]);

    // 定义表格工具栏
    var tbar = [{
        xtype: "tbbutton",
        minWidth: 80,
        ref: '../addBtn',
        text: "添加项",
        cls: "x-btn-text-icon",
        icon: "/Content/icons/add.png",
        handler: function (btn, e) {
            //showWinTest();
            showCifCustEditFormWinFn(id);
            //showCifCustEditFormWinFn(CifCustFormReader, "添加车辆信息");
            //Fs.Car.CarForm.showCarEditFormWinFn(CarInfoFormReader, "添加客户信息", itemGridStore)
        }
    }, "-", {
        xtype: "tbbutton",
        ref: '../delBtn',
        minWidth: 80,
        disabled: true,
        text: "删除项",
        cls: "x-btn-text-icon",
        icon: "/Content/icons/delete.png",
        handler: function (btn, e) {
            JsHelper.DelConfirm(function (btn) {
                if (btn == 'yes') {
                    // gridEditor.stopEditing();
                    var s = grid.getSelectionModel().getSelections();
                    for (var i = 0, r; r = s[i]; i++) {
                        itemGridStore.remove(r);
                    }
                }
            });
        }
    }, "-", {
        xtype: "tbbutton",
        minWidth: 80,
        text: "双击修改项",
        cls: "x-btn-text-icon",
        icon: "/Content/icons/pencil.png",
        disabled: true
    }];

    // 分页工具栏
    var bbar = new Ext.PagingToolbar({
        displayInfo: true,
        emptyMsg: "没有数据显示",
        displayMsg: "{0}到{1}条，共{2}条",
        store: itemGridStore,
        pageSize: ALL_PAGESIZE_SETTING,
        plugins: [filters]
    });

    // 客户信息维护表格
    var grid = new Ext.grid.GridPanel({
        enableColumnMove: false,
        sm: sm,
        cm: cm,
        plugins: [filters],
        stripeRows: true,
        frame: true,
        border: true,
        layout: "fit",
        store: itemGridStore,
        loadMask: true,
        tbar: tbar,
        bbar: bbar,
        listeners: {
            "rowdblclick": function (g, rowIndex, e) {
                var store = g.getStore()
                var id = store.getAt(rowIndex).get("Id");
                //alert("id is : " + id);
                showCifCustEditFormWinFn(CifCustFormReader, "客户信息维护", id);
            }
        }
    });

    // 控制删除按钮
    grid.getSelectionModel().on('selectionchange', function (sm) {
        grid.delBtn.setDisabled(sm.getCount() < 1);
    });

    // 客户基本信息
    var CifCustBaseForm = function (id) {

        var column1 = [{
            fieldLabel: '客户号',
            width: 150,
            name: 'CustNo'
        }, {
            fieldLabel: '客户姓名',
            width: 150,
            name: 'CustNa'
        }, {
            fieldLabel: '证件类型',
            width: 150,
            name: 'CertTp'
        }, {
            fieldLabel: '证件号码',
            width: 150,
            name: 'CertNo'
        }];

        var column2 = [{
            fieldLabel: '性别',
            width: 150,
            name: 'Gender'
        }, {
            fieldLabel: '手机',
            width: 150,
            name: 'MobiTL'
        }, {
            fieldLabel: '办公电话',
            width: 150,
            name: 'OffiTL'
        }, {
            fieldLabel: '家庭电话',
            width: 150,
            name: 'HomeTL'
        }];

        var column3 = [{
            fieldLabel: '邮编',
            width: 150,
            name: 'MailCD'
        }, {
            fieldLabel: '地址',
            width: 150,
            name: 'MailAD'
        }, {
            fieldLabel: 'EMail',
            width: 150,
            name: 'E_Mail'
        }];

        // 定义表单 头部固定为两列 末尾单独列 需要改变布局时再修改
        var form = new Ext.FormPanel({
            border: false,
            waitMsgTarget: true,
            labelWidth: 60, // 注意 使用时 如果有表单内组件有特殊标签名称长度很大 替换合适的标签长度
            height : 200,
            frame: true,
            //bodyStyle: 'padding:5px 5px 0',
            //reader: BCarInfoFormReader, // 注意 这是传入方法的 Ext.data.DataReader 类型
            // 这里的借用表格store的reader属性
            labelAlign: 'right',
            items: [{
                layout: 'column', // 注意 现在使用的是两列 要是三列或更多
                // 请改变下面的items
                // 并在上面定义每个列的组件集合
                items: [{
                    columnWidth: .3,
                    bodyStyle: 'padding:1px',
                    layout: 'form',
                    defaultType: 'textfield',
                    items: column1
                }, {
                    columnWidth: .3,
                    bodyStyle: 'padding:1px',
                    layout: 'form',
                    defaultType: 'textfield',
                    items: column2
                }, {
                    columnWidth: .3,
                    bodyStyle: 'padding:1px',
                    layout: 'form',
                    defaultType: 'textfield',
                    items: column3
                }]
            }],
            buttonAlign: 'center',
            buttons: [new Ext.ux.SubmitBtn({
                handler: function () {
                    if (form.getForm().isValid()) {
                        form.getForm().submit({
                            url: '/BCar/SaveOrUpdate',
                            params: {
                                'AuthorizeUsers': UserCombo.getValue(),
                                'Id': (updateEdit) ? id : ""
                            },
                            success: function (form, action) {
                                itemGridStore.setDefaultSort('CreateTime', 'DESC');
                                itemGridStore.load({// 刷新表格
                                    params: {
                                        start: 0,
                                        limit: ALL_PAGESIZE_SETTING
                                    }
                                });
                                win.destroy(); // 关闭窗口
                            },
                            failure: function (form, action) {
                                JsHelper.ShowError(action.result.msg);
                            }
                        }); // formSubmitArgs
                        // 引用之前定义的请求参数变量
                    }
                }
            }), new Ext.ux.CancelBtn({
                handler: function () {
                    win.destroy();
                }
            })]
        });
        return form;
    };

    // 客户车辆信息
    var CifCustCarGrid = function (id) {

        // 客户车辆信息基本项
        var CifCustCarFields = new Array(
            { name: 'Id', type: 'string' },
            { name: 'TDeport', type: 'string' },
            { name: 'CurrentDep', type: 'string' },
            { name: 'Brand', type: 'string' },
            { name: 'Model', type: 'string' },
            { name: 'Color', type: 'string' },
            { name: 'Engin_ID', type: 'string' },
            { name: 'Frame_ID', type: 'string' },
            { name: 'Prod_Date', type: 'string' },
            { name: 'CarNo', type: 'string' },
            { name: 'SellDate', type: 'string' }
        );

        // 定义filters
        var filters = new Ext.ux.grid.GridFilters({
            encode: true,
            filters: [{
                dataIndex: 'Brand', // 品牌
                options: ['丰田', '大众', '本田'],
                //options : DeptStore.collect('Name'),
                type: 'list'
            }]
        });

        //查询语句
        filters.buildQuery = function (filters) {
            var p = {}, i, f, root, dataPrefix, key, tmp, len = filters.length;
            if (!this.encode) {
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    root = [this.paramPrefix, '[', i, ']'].join('');
                    p[root + '[field]'] = f.field;

                    dataPrefix = root + '[data]';
                    for (key in f.data) {
                        p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
                    }
                }
            } else {
                tmp = [];
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    tmp.push(Ext.apply({}, {
                        field: f.field
                    }, f.data));
                }
                if (tmp.length > 0) {
                    p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
                }
            }
            return p;
        };

        // 定义表单 客户车辆信息Reader
        var CifCustCarReader = new Ext.data.JsonReader({
            root: 'data',
            fields: CifCustCarFields
        });

        // 定义表格 客户车辆信息store
        var CifCustCarGridStore = new Ext.data.Store({
            url: "/BCar/GetPlistAll",
            remoteSort: true,
            reader: new Ext.data.JsonReader({
                root: 'data',
                totalProperty: 'total',
                id: 'Id',
                fields: CifCustCarFields
            }),
            listeners: {
                'remove': function (thiz, record, index) {
                    Ext.Ajax.request({
                        url: '/CifCust/Delete?Id=' + record.data.Id,
                        success: function (response, opts) {
                            var result = Ext.util.JSON.decode(response.responseText);
                            if (result.success == false) {
                                JsHelper.ShowError(result.msg);
                                itemGridStore.insert(0, record);
                            }
                        }
                    });
                }
            }
        });
        CifCustCarGridStore.setDefaultSort('CreateTime', 'ASC'); // 设置默认排序

        // 定义表格选择方式
        var sm = new Ext.grid.CheckboxSelectionModel();

        // 定义Grid表格列
        var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), sm, {
            header: "车牌号",
            dataIndex: 'CarNo',
            sortable: true
        }, {
            header: "总仓",
            dataIndex: 'TDeport',
            sortable: true
        }, {
            header: "展场",
            dataIndex: 'CurrentDep',
            sortable: true
        }, {
            header: "品牌",
            dataIndex: 'Brand',
            sortable: true
        }, {
            header: "型号",
            dataIndex: 'Model'
        }, {
            header: "颜色",
            dataIndex: 'Color'
        }, {
            header: "发动机号",
            dataIndex: 'Engin_ID'
        }, {
            header: "车架号",
            dataIndex: 'Frame_ID'
        }, {
            header: "出厂日期",
            width: 90,
            dataIndex: 'Prod_Date',
            sortable: true,
            xtype: 'datecolumn',
            format: 'Y年m月d日'
        }, {
            header: "销售日期",
            dataIndex: 'SellDate',
            width: 90,
            sortable: true,
            xtype: 'datecolumn',
            format: 'Y年m月d日'
        }]);

        // 定义表格工具栏
        var tbar = [{
            xtype: "tbbutton",
            minWidth: 80,
            ref: '../addBtn',
            text: "添加项",
            cls: "x-btn-text-icon",
            icon: "/Content/icons/add.png",
            handler: function (btn, e) {
                //showCifCustEditFormWinFn(CifCustFormReader, "添加车辆信息");
                //Fs.Car.CarForm.showCarEditFormWinFn(CarInfoFormReader, "添加客户信息", itemGridStore)
            }
        }, "-", {
            xtype: "tbbutton",
            ref: '../delBtn',
            minWidth: 80,
            disabled: true,
            text: "删除项",
            cls: "x-btn-text-icon",
            icon: "/Content/icons/delete.png",
            handler: function (btn, e) {
                JsHelper.DelConfirm(function (btn) {
                    if (btn == 'yes') {
                        // gridEditor.stopEditing();
                        var s = gridCifCustCar.getSelectionModel().getSelections();
                        for (var i = 0, r; r = s[i]; i++) {
                            itemGridStore.remove(r);
                        }
                    }
                });
            }
        }, "-", {
            xtype: "tbbutton",
            minWidth: 80,
            text: "双击修改项",
            cls: "x-btn-text-icon",
            icon: "/Content/icons/pencil.png",
            disabled: true
        }];

        // 分页工具栏
        var bbar = new Ext.PagingToolbar({
            displayInfo: true,
            emptyMsg: "没有数据显示",
            displayMsg: "{0}到{1}条，共{2}条",
            store: itemGridStore,
            pageSize: ALL_PAGESIZE_SETTING,
            plugins: [filters]
        });

        // 客户信息维护表格
        var gridCifCustCar = new Ext.grid.GridPanel({
            enableColumnMove: false,
            sm: sm,
            cm: cm,
            plugins: [filters],
            stripeRows: true,
            frame: true,
            border: true,
            layout: "fit",
            store: CifCustCarGridStore,
            loadMask: true,
            tbar: tbar,
            bbar: bbar,
            listeners: {
                "rowdblclick": function (g, rowIndex, e) {
                    var store = g.getStore()
                    var id = store.getAt(rowIndex).get("Id");
                    //alert("id is : " + id);
                    //showCifCustEditFormWinFn(CifCustFormReader, "客户信息维护", id);
                }
            }
        });

        // 控制删除按钮
        gridCifCustCar.getSelectionModel().on('selectionchange', function (sm) {
            gridCifCustCar.delBtn.setDisabled(sm.getCount() < 1);
        });

        return gridCifCustCar;
    }

    // 售后维修信息
    var CarMaintenanceGrid = function (id) {

        // 车辆维修信息基本项
        var CarMaintenanceFields = new Array(
            { name: 'Id', type: 'string' },
            { name: 'MtDept', type: 'string' },
            { name: 'CarNo', type: 'string' },
            { name: 'MtBgDt', type: 'string' },
            { name: 'MtEndt', type: 'string' },
            { name: 'RcUser', type: 'string' },
            { name: 'MtUser', type: 'string' },
            { name: 'MtUser', type: 'string' },
            { name: 'StCost', type: 'string' },
            { name: 'Frame_ID', type: 'string' },
            { name: 'Prod_Date', type: 'string' },
            { name: 'CarNo', type: 'string' },
            { name: 'Description', type: 'string' }
        );

        // 定义filters
        var filters = new Ext.ux.grid.GridFilters({
            encode: true,
            filters: [{
                dataIndex: 'Brand', // 品牌
                options: ['丰田', '大众', '本田'],
                //options : DeptStore.collect('Name'),
                type: 'list'
            }]
        });

        //查询语句
        filters.buildQuery = function (filters) {
            var p = {}, i, f, root, dataPrefix, key, tmp, len = filters.length;
            if (!this.encode) {
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    root = [this.paramPrefix, '[', i, ']'].join('');
                    p[root + '[field]'] = f.field;

                    dataPrefix = root + '[data]';
                    for (key in f.data) {
                        p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
                    }
                }
            } else {
                tmp = [];
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    tmp.push(Ext.apply({}, {
                        field: f.field
                    }, f.data));
                }
                if (tmp.length > 0) {
                    p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
                }
            }
            return p;
        };

        // 定义表单 客户车辆信息Reader
        var CarMaintenanceReader = new Ext.data.JsonReader({
            root: 'data',
            fields: CarMaintenanceFields
        });

        // 定义表格 客户车辆信息store
        var CarMaintenanceGridStore = new Ext.data.Store({
            url: "/BCar/GetPlistAll",
            remoteSort: true,
            reader: new Ext.data.JsonReader({
                root: 'data',
                totalProperty: 'total',
                id: 'Id',
                fields: CarMaintenanceFields
            }),
            listeners: {
                'remove': function (thiz, record, index) {
                    Ext.Ajax.request({
                        url: '/CifCust/Delete?Id=' + record.data.Id,
                        success: function (response, opts) {
                            var result = Ext.util.JSON.decode(response.responseText);
                            if (result.success == false) {
                                JsHelper.ShowError(result.msg);
                                itemGridStore.insert(0, record);
                            }
                        }
                    });
                }
            }
        });
        CarMaintenanceGridStore.setDefaultSort('CreateTime', 'ASC'); // 设置默认排序

        // 定义表格选择方式
        var sm = new Ext.grid.CheckboxSelectionModel();

        // 定义Grid表格列
        var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), sm, {
            header: "车牌号",
            dataIndex: 'CarNo',
            sortable: true
        }, {
            header: "总仓",
            dataIndex: 'TDeport',
            sortable: true
        }, {
            header: "展场",
            dataIndex: 'CurrentDep',
            sortable: true
        }, {
            header: "品牌",
            dataIndex: 'Brand',
            sortable: true
        }, {
            header: "型号",
            dataIndex: 'Model'
        }, {
            header: "颜色",
            dataIndex: 'Color'
        }, {
            header: "发动机号",
            dataIndex: 'Engin_ID'
        }, {
            header: "车架号",
            dataIndex: 'Frame_ID'
        }, {
            header: "出厂日期",
            width: 90,
            dataIndex: 'Prod_Date',
            sortable: true,
            xtype: 'datecolumn',
            format: 'Y年m月d日'
        }, {
            header: "销售日期",
            dataIndex: 'SellDate',
            width: 90,
            sortable: true,
            xtype: 'datecolumn',
            format: 'Y年m月d日'
        }]);

        // 定义表格工具栏
        var tbar = [{
            xtype: "tbbutton",
            minWidth: 80,
            ref: '../addBtn',
            text: "添加项",
            cls: "x-btn-text-icon",
            icon: "/Content/icons/add.png",
            handler: function (btn, e) {
                //showCifCustEditFormWinFn(CifCustFormReader, "添加车辆信息");
                //Fs.Car.CarForm.showCarEditFormWinFn(CarInfoFormReader, "添加客户信息", itemGridStore)
            }
        }, "-", {
            xtype: "tbbutton",
            ref: '../delBtn',
            minWidth: 80,
            disabled: true,
            text: "删除项",
            cls: "x-btn-text-icon",
            icon: "/Content/icons/delete.png",
            handler: function (btn, e) {
                JsHelper.DelConfirm(function (btn) {
                    if (btn == 'yes') {
                        // gridEditor.stopEditing();
                        var s = gridCarMaintenance.getSelectionModel().getSelections();
                        for (var i = 0, r; r = s[i]; i++) {
                            itemGridStore.remove(r);
                        }
                    }
                });
            }
        }, "-", {
            xtype: "tbbutton",
            minWidth: 80,
            text: "双击修改项",
            cls: "x-btn-text-icon",
            icon: "/Content/icons/pencil.png",
            disabled: true
        }];

        // 分页工具栏
        var bbar = new Ext.PagingToolbar({
            displayInfo: true,
            emptyMsg: "没有数据显示",
            displayMsg: "{0}到{1}条，共{2}条",
            store: itemGridStore,
            pageSize: ALL_PAGESIZE_SETTING,
            plugins: [filters]
        });

        // 客户信息维护表格
        var gridCarMaintenance = new Ext.grid.GridPanel({
            enableColumnMove: false,
            sm: sm,
            cm: cm,
            plugins: [filters],
            stripeRows: true,
            frame: true,
            border: true,
            layout: "fit",
            store: CarMaintenanceGridStore,
            loadMask: true,
            tbar: tbar,
            bbar: bbar,
            listeners: {
                "rowdblclick": function (g, rowIndex, e) {
                    var store = g.getStore()
                    var id = store.getAt(rowIndex).get("Id");
                    //alert("id is : " + id);
                    //showCifCustEditFormWinFn(CifCustFormReader, "客户信息维护", id);
                }
            }
        });

        // 控制删除按钮
        gridCarMaintenance.getSelectionModel().on('selectionchange', function (sm) {
            gridCarMaintenance.delBtn.setDisabled(sm.getCount() < 1);
        });

        return gridCarMaintenance;
    }

    // 显示客户详细信息。
    var showCifCustEditFormWinFn = function (id) {

        // 客户基本信息Form
        var custBaseInfoForm = CifCustBaseForm(id);
        
        // 客户拥有车辆信息Grid
        var custCarGrid = CifCustCarGrid(id);

        // 客户售后维修记录
        var carMaintenanceGrid = CarMaintenanceGrid(id);

        var userDetailTab = new Ext.TabPanel({
            id: "Cust_DetailTab",
            frame: true,
            border: true,            
            autoScroll: true,
            enableTabScroll: true,
            height:400,
            activeTab: 0,
            items: [new Ext.Panel({
                id: 'Cust_DetailTab_CarList',
                title: '车辆',
                autoScroll: true,
                layout: 'fit',
                border: false,
                items: [custCarGrid]
            }), new Ext.Panel({
                id: 'Cust_DetailTab_MaintenanceList',
                title: '维护',
                autoScroll: true,
                layout: 'fit',
                border: false,
                items: [carMaintenanceGrid]
            })
            ]
        });

        custBaseInfoForm.region = 'center';
        custBaseInfoForm.maxheight = '200';
        //userDetailTab.height = '300';
        userDetailTab.region = 'south';

        // 定义显示窗口
        var win = new Ext.Window({
            title: '客户信息维护',
            iconCls: 'application_form',
            width: 800,
            height: 600,
            layout: 'border',
            resizable: false,
            constrain: true,
            //autoHeight: true,
            modal: true,
            closeAction: 'close',
            plain: true,
            items: [custBaseInfoForm, userDetailTab]
        });

        win.show();
    };

    var showWinTest = function () {

        var form = new Ext.FormPanel({
            height: 200,
            width: 294,
            title: 'My Form',
            region: 'center'
        });

        // 客户拥有车辆信息Grid
        var custCarGrid = CifCustCarGrid(id);
        custCarGrid.region = 'east';
        custCarGrid.width = '400';


        var win = new Ext.Window({
            height: 600,
            width: 800,
            layout: 'border',
            resizable: false,
            constrain: true,
            modal: true,
            closeAction: 'close',
            plain: true,
            items: [form, custCarGrid],
            title: 'My Window'
        });

        alert("show Win");

        win.show();
    };

    // 加载
    JsHelper.ExtTabDoLayout(grid);
    itemGridStore.load({
        params: {
            start: 0,
            limit: ALL_PAGESIZE_SETTING
        }
    });
};

CifCust();

